package com.rui.shangXueTang.huffman;

/**
 * @author : [锐神NO.3]
 * @version : [v1.0]
 * @className : Node
 * @createTime : [2022/2/17 21:15]
 * @description : [描述该类的功能]
 */

public class Node implements Comparable<Node> {

    public int value;

    public Node left;

    public Node right;

    public Node(int value) {
        this.value = value;
    }

    /**
     *
     * @param node
     * @return int
     */
    @Override
    public int compareTo(Node node) {
        return this.value - node.value;
    }

    @Override
    public String toString() {
        return "Node{" +
                "value=" + value +
                '}';
    }

    /**
     * 前序遍历
     */
    public void preSelect(){
        System.out.println(this);

        if(this.left != null){
            this.left.preSelect();
        }

        if(right != null){
            this.right.preSelect();
        }
    }
}
